using System;
using System.Collections.Generic;
using System.Text;
using Evolution.Engine.Objects;
using System.Collections.ObjectModel;
using Evolution.Engine.Interfaces;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Evolution.Engine.Managers
{
    public class PlayerManager : Singleton<PlayerManager>, Evolution.Engine.Interfaces.IUpdateable, IRenderable, ILoadable
    {
        private Dictionary<string, Player> _Player = new Dictionary<string, Player>();
        private string _Current = "";

        public Player Player = null;

        public void Add(Player player)
        {
            if (!_Player.ContainsKey(player.Name))
                _Player.Add(player.Name, player);

            _Current = player.Name;
            Player = player;
        }

        public bool Contains(Player player)
        {
            return Contains(player.Name);
        }

        public bool Contains(string name)
        {
            return _Player.ContainsKey(name);
        }

        #region ILoadable Members

        public void LoadContent()
        {
            if( Player != null )
                Player.LoadContent();
        }

        #endregion

        #region IRenderable Members

        public void Render(GameTime gameTime)
        {
            if (Player != null)
                Player.Draw(gameTime);
        }

        #endregion

        #region IUpdateable Members

        public void Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            if (Player != null)
                Player.Update(gameTime);
        }

        #endregion
    }
}
